﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Lucene.Net.Index;
using Lucene.Net.Documents;
using System.IO;
using Lucene.Net.Store;
using Lucene.Net.Analysis.Standard;


namespace MvcDemo.Move.Controllers
{
    public class IndexerController : Controller
    {
        //
        // GET: /Indexer/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Search(string keyword)
        {

            return View();
        }

        public ActionResult Create()
        {
            //string INDEX_DIR = @"E:\资料\Lucene\Lucene原理与代码分析完整版\indexDir";
            //IndexWriter writer = new IndexWriter(FSDirectory.Open(new DirectoryInfo(INDEX_DIR)), new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), true, IndexWriter.MaxFieldLength.LIMITED);
            //foreach (var file in System.IO.Directory.EnumerateFiles(@"E:\Work\EnnB2B\Document\产品需求\JBK_20101231_1315\JBK", "*", System.IO.SearchOption.AllDirectories))
            //{
            //    Document doc = new Document();
            //    doc.Add(new Field("path", file, Field.Store.YES, Field.Index.NOT_ANALYZED));
            //    doc.Add(new Field("modified", DateTools.TimeToString(new FileInfo(file).LastWriteTime.Millisecond,
            //                DateTools.Resolution.MINUTE), Field.Store.YES, Field.Index.NOT_ANALYZED));
            //    doc.Add(new Field("contents", new StreamReader(file)));

            //    writer.AddDocument(doc);

            //    Console.Out.WriteLine(file);
            //}
            //writer.Optimize();
            //writer.Close();
            return View();
        }

        [HttpPost]
        public ActionResult Create(int id)
        {

            return View();
        }

    }
}
